<template>
  <div class="home">
     <div v-back="$store.state.color">我是一个主题</div>
     <button v-back="$store.state.color">我是一个按钮</button>
     <button @click="cut">切换颜色</button>
     <el-button type="primary">Primary</el-button>
     <el-rate v-model="value1" />
  </div>
</template>

<script>
// @ is an alias to /src
import { useStore } from 'vuex';
import { ElButton, ElRate } from 'element-plus';
import { ref } from 'vue';
export default {
  name: 'HomeView',
  components: {
    ElButton,
    ElRate
  },
  setup(props) {
    const { commit } = useStore();
    const value1 = ref(10);
    const cut = () => {
      // Math.random() 0-1的随机数
      // Math.random().toString(16) 转换成一个 16 进制的随机数
      let color = "#" + Math.random().toString(16).substr(2,6);
      commit('cutColor',color);
    }
    return {
      cut,
      value1
    }
  }

}
</script>
